# 定义一个函数来转换日期格式
def convert_date(date_str):
    months = {
        "January": "01", "February": "02", "March": "03", "April": "04",
        "May": "05", "June": "06", "July": "07", "Augest": "08",
        "September": "09", "Octorber": "10", "November": "11", "December": "12"
    }
    parts = date_str.split()
    month = months[parts[0]]
    day = parts[1].replace(",", "")
    year = parts[2]
    return f"{year}-{month}-{day}"

# 读取输入文件，转换日期格式，并写入输出文件
input_file = 'date.tbl'
output_file = 'dates.tbl'

with open(input_file, 'r') as infile, open(output_file, 'w') as outfile:
    for line in infile:
        fields = line.strip().split('|')
        if len(fields) > 1:  # 确保行有足够的字段
            fields[1] = convert_date(fields[1])  # 转换第二列的日期格式
        outfile.write('|'.join(fields) + '\n')

print(f"Conversion completed. Output is in {output_file}")